/**
 * 				AccessClipboard.java
 *				------------
 *		
 *   Author:	bin04017
 *   ID:		bin04017
 *	 Created:	24.01.2007
 *	 Project:	Mochito
 *	 Package:	tools.clipboard
 *	 Usage:		
 */
package mochito.tools.clipboard;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;

public class AccessClipboard {
	
	public static String getClipboard() {
		Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		Transferable clipboardContents = systemClipboard.getContents(null);
		if (clipboardContents == null) {
			return ("");
		} else
			try {
				if (clipboardContents.isDataFlavorSupported(DataFlavor.stringFlavor)) {
					String returnText = (String) clipboardContents.getTransferData(DataFlavor.stringFlavor);
					return returnText;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		return null;
	}

	public static void writeToClipboard(String writeMe) {
		Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		Transferable transferableText = new StringSelection(writeMe);
		systemClipboard.setContents(transferableText, null);
	}

	
}
